$(document).ready(function(){
	initViewHistoryDialog();
	closeViewHistoryDialog();
	/*$('#viewHistoryDataGrid').datagrid({
		onLoadSuccess:function(data){
			$(this).datagrid('doCellTip',{'max-width':'300px','delay':500});
		}
	});*/
});


/**
 * 加载数据
 * @param tableName
 * @param modelId
 */
function viewHistory(tableName, modelId){
	var Id = "";
	if(tableName == 'sys_purviews'){
		Id = $('#tt').tree('getSelected').id;
		$('#viewHistoryDataGrid').datagrid({ url:"sys/viewHistory.action",
			queryParams:{"sysOperatorLog.operatorTable" : tableName,
						"sysOperatorLog.operatorTableId" : Id},
			method:"post",
			onLoadSuccess:function(data){
				$(this).datagrid('doCellTip',{contentStyler:{backgroundColor:'#f7f5d1', paddingLeft:'5px'}});
			}
		});
		initViewHistoryDialog();
	}else{
		if($('#dataGridTable').datagrid('getSelected')){
			Id = $('#dataGridTable').datagrid('getSelections')[0][modelId];
			$('#viewHistoryDataGrid').datagrid({ url:"sys/viewHistory.action",
				queryParams:{"sysOperatorLog.operatorTable" : tableName,
							"sysOperatorLog.operatorTableId" : Id},
				method:"post",
				onLoadSuccess:function(data){
					$(this).datagrid('doCellTip',{contentStyler:{backgroundColor:'#f7f5d1', paddingLeft:'5px'}});
				}
			});
			initViewHistoryDialog();
		}
		else
		{
			noSelectData();
		}
	}
}

/**--------------操作弹出框------------------**/
//初始化模窗
function initViewHistoryDialog(){
	$('#viewHistoryDialog').dialog({
		title:'操作记录',
		modal: true,
		collapsible : true,
		resizable : true,
		onClose : function(){
			
		}
	});
}

//操作类型
function operatorTypeChange(value,row,index){
	var text='';
	if(value== undefined){
		text='';
	} else if(value=='1'){
		text='创建';
	} else if(value=='2'){
		text='删除';
	} else if(value=='3'){
		text='修改';
	} else if(value=='4'){
		text='查询';
	}
	return text;
}

//关闭
function closeViewHistoryDialog(){
	$("#viewHistoryDialog").dialog('close');
}
